result = 1 != 1
print(result)

# 1
d1 = {'f': 70, 'C': 67}
print(d1.get('C'))

# 2
# 可以

# 3

# 4
a = dict(one=1, two=2, three=3)
b = {'one': 1, 'two': 2, 'three': 3}
c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
d = dict([('two', 2), ('one', 1), ('three', 3)])
e = dict({'one': 1, 'two': 2, 'three': 3})

print(a)
print(b)
print(c)
print(d)
print(e)

# 5
data = '1000,小甲鱼,男'
mdict = {}
(mdict['id'], mdict['name'], mdict['sex']) = (data.split(',')[0], data.split(',')[1], data.split(',')[2])
print('id:  ' + mdict['id'])
print('name:' + mdict['name'])
print('sex: ' + mdict['sex'])

print('---欢迎进入通讯录程序---')
print('---1：查询联系人资料---')
print('---2：插入新的联系人---')
print('---3：删除已有联系人---')
print('---4：退出通讯录程序---')
exm = {'name':'tom','number':'10010'}
contact = [{'name':'tom','number':'10010'}]


def findUser(name,contacts):
    '返回1则有,0则无'
    result = {}
    for each in contacts:
        if each['name'] == name:
            result = each
            break
    return result

while 1:
    code = input('请输入相关的指令代码')
    code = int(code)
    if code == 1:
        # 查询联系人并打印
        name = input('请输入联系人姓名')
        result = findUser(name,contact)
        if result:
            print(result['name'],result['number'])
        else:
            print('没有该用户信息')
    elif code == 2:
        # 插入新的联系人
        name = input('请输入联系人姓名')
        result = findUser(name, contact)
        if result:
            print('该用户已存在',result['name'],result['number'])
            notice = input('是否修改用户资料(yes/no):')
            notice = notice.lower()
            if notice == 'yes':
                number = input('请输入用户联系电话:')
                result['number'] = number
            elif notice == 'no':
                pass
            else:
                pass

    elif code == 3:
        # 删除已有联系人
        name = input('请输入联系人姓名')
        result = findUser(name, contact)
        if result:
            contact.remove(result)
        else:
            print('没有该用户信息')
    elif code == 4:
        # 退出通讯录程序
        break
    else:
        #exm
        print(contact)
        pass



